package com.five;

public class Demo3 {
    public static void main(String[] args) {

        Menus[] menus = new Menus[5];
        Menus menus1 = new Menus();
        //menus1.id=(int)Math.floor(Math.random()*100);
        menus1.id=1;
        menus1.mName="炒土豆丝";
        menus1.mPrice=12.5;
        menus1.count=10;

        Menus menus2 = new Menus();
        menus2.id=2;
        menus2.mName="红烧肉";
        menus2.mPrice=25.4;
        menus2.count=10;

        Menus menus3 = new Menus();
        menus3.id=3;
        menus3.mName="西红柿炒鸡蛋";
        menus3.mPrice=10;
        menus3.count=10;

        menus[0]=menus1;
        menus[1]=menus2;
        menus[2]=menus3;

        Menus menu = checkMenuById(1, menus);

        Menus menus4 = new Menus();
        menus4.id=menu.id;
        menus4.mName=menu.mName;
        menus4.mPrice=menu.mPrice;
        menus4.sumCount=3;
    }

    //检验输入的菜品是否在菜单中
    public static Menus checkMenuById(int id,Menus[] menus){
        for (int i = 0; i <menus.length ; i++) {
            if(menus[i] !=null && menus[i].id==id){
                return menus[i] ;
            }
        }
        return null;
    }
}
